// $Id: networktopologizerrandom.cpp 74 2005-05-15 19:54:19Z hansemil $
#include "networktopologizerrandom.h"
#include <list>

#include <iostream>

/**
 * @param nodes A pointer to the Node STL list
 * @param newNeighborCount The number of random neighbors that should be added to each node
 */
NetworkTopologizerRandom::NetworkTopologizerRandom(list<Node *> *nodes, int newNeighborCount)
	: NetworkTopologizer(nodes)
{
	int j;

	// Create second node list to randomize
	std::list<Node *> randNodes = *nodes;

	// Build topology
	std::list<Node *>::iterator randNode;
	for(int i=0; i<newNeighborCount; i++){
		randNodes.sort(SortRandomHelper());
		randNode=randNodes.begin();
		j = 0;
		for (std::list<Node *>::iterator node=(*m_nodes).begin(); node!=(*m_nodes).end(); node++) {
			(*randNode)->addNeighbor(*node, nodeKeys[j]);
			randNode++;
			j++;
		}
	}
}

NetworkTopologizerRandom::~NetworkTopologizerRandom()
{
}
